package com.warrior.superdata.mysql.entity.dto;

import com.warrior.superdata.annotation.MysqlCheckInject;
import com.warrior.superdata.base.BaseDto;
import com.warrior.superdata.mysql.mapper.ApiDatasourceMapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @Description:
 * @ClassName: ApiDatasourceDto.java
 * @date: 2022/3/2 16:19
 * @author xujian
 */
@Data
@MysqlCheckInject(mapper = ApiDatasourceMapper.class)
public class ApiDatasourceDto extends BaseDto {

    @MysqlCheckInject(uniqueField = "datasource_code")
    @NotBlank(message = "数据源唯一编码不能为空")
    @ApiModelProperty(value = "数据源唯一编码")
    private String datasourceCode;

    @NotBlank(message = "数据源名称不能为空")
    @ApiModelProperty(value = "数据源名称")
    private String datasourceName;

    @ApiModelProperty(value = "数据库名称")
    private String databaseName;

    @MysqlCheckInject(conditionUniqueField = {"ip", "port", "type", "database_name"})
    @ApiModelProperty(value = "数据源类型 1-mysql 2-es")
    @NotNull(message = "数据源类型不能为空")
    private Integer type;

    @ApiModelProperty(value = "数据源ip")
    @NotBlank(message = "数据源ip不能为空")
    private String ip;

    @ApiModelProperty(value = "数据源端口")
    @NotBlank(message = "数据源端口不能为空")
    private String port;

    @ApiModelProperty(value = "数据源账号")
    private String username;

    @ApiModelProperty(value = "数据源密码")
    private String password;

}
